'use strict';
const getdate = require("getdate")
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const {name,md,tags,cover} = event
  if(name)
  {
    const db = uniCloud.database()
    let date = getdate()
    const dbRes = await db.collection("books").add([{
  "name":name,
  "md":md,
  "tags":tags,
  "date":date,
  "cover":cover
  }])
    return {
      Code:1,
      data:dbRes.result
    }
  }
  else
  return {
    Code: 0,
    errMsg: 'book_name不能为空'
  }

	//返回数据给客户端
};
